var data = '<?php echo $this->xml ?>';

var baseIcon = new GIcon();
baseIcon.image = 'http://<?php echo WSB_HOST . WSB_URL ?>WSB/xtensions/sherpa/etc/GoogleMapIconSherpa.png';
baseIcon.iconSize = new GSize(31, 29);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);

function loadGoogleMap() {
  if (GBrowserIsCompatible()) {
  
    var xml = GXml.parse(data);
    var markers = xml.documentElement.getElementsByTagName("marker");
    var html = markers[0].firstChild.data;
    var lat = parseFloat(markers[0].getAttribute("lat"));
    var lng = parseFloat(markers[0].getAttribute("lng"));
    var zoom = parseInt(markers[0].getAttribute("zoom"));
    var point = new GLatLng(lat, lng);
    var marker = createMarker(point, html);

    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    map.addOverlay(marker);
    map.setCenter(new GLatLng(lat, lng), zoom);

  }
}

function createMarker(point, html) {
  var marker = new GMarker(point, baseIcon);
  marker.openInfoWindowHtml(html);
  GEvent.addListener(marker, 'click', function() {
    marker.openInfoWindowHtml(html);
  });
  return marker;
}

function goToStore(select)
{
    var index = select.selectedIndex;
    if(index > 0) {
        var url = select.options[index].value;
        if(url != '') {
            window.location.href = url;
        }
    }
}

window.onload = loadGoogleMap;
